package com.admin.action.bookaction;

import com.admin.Action;
import com.admin.service.bookservice.BookServiceImpl;
import com.admin.service.bookservice.BookServiceInF;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 图书的下架
 */
public class BookLowerAction extends Action {
    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out=response.getWriter();
        //判断是否是当前操作员

        HttpSession session = request.getSession();
//        System.out.println(session.getAttribute("adminInfo"));
        if(session.getAttribute("adminInfo")==null){
            out.println("<script>parent.window.location.href='error.html';</script>");
            return;
        }
        BookServiceInF service= new BookServiceImpl();
        int bookid= Integer.parseInt(request.getParameter("id"));
        System.out.println("书籍id"+bookid);
        if(service.delBooks(bookid)){
            out.print("下架成功");
        }else {
            out.print("下架失败");
        }






    }
}
